<template>
	<div class="search">
		<div class="top">
			<back></back>
			<input type="" name="" placeholder="请输入关键字" v-model="inValue">
			<router-link :to='{name:"result",query:{key:inValue}}'>
				<button @click="addList()">搜索</button>
			</router-link>
		</div>
		<div class="main">
			<ul>
				<search-history 
					v-for="(item,index) of inList"
					:value="item"
					:key='index'
					:index='index'
					@deleteThis='deleteThis(index)'
				>
				</search-history>
			</ul>
		</div>
	</div>
</template>
<script >
	import $ from 'jquery'
	import searchHistory from './searchHistory'
	import back from '../public/back'
	export default {
		components:{
			'search-history':searchHistory,
			back:back
		},
		data:function () {
			return {
				inValue:'',
				inList:[]
			}
		},
		
        methods: {
        	addList:function () {
        		if (this.inList.length>=10) {
        			this.inList.splice(10,1);
        		}
        		if (this.inValue!='') {
        			this.inList.unshift(this.inValue);//前面添加
        			this.inValue = '';
        		}
        	},
        	deleteThis:function (index) {
        		this.inList.splice(index,1);
        	}
        },
        created:function () 
        {
            var that = this;
            $.ajax({
                type:"get",
                // url:"http://juhuituan.boguyuan.com/juhuituan/reqData?action=listFocusAd&acode=1&uid=25177",
                url:'http://op.juhe.cn/onebox/basketball/combat?key=b5ca2acdab01c88c99d532cdfb5c3aa2&hteam=骑士?vtem=勇士',
                dataType:"json",
                success:function (data) 
                {
                    // console.log(data);
                }
            });
        },
	}
</script>
<style scoped>
	@import "../../assets/css/search.css"
</style>